<template>
	<view class="pb-2">
		<view class="m-2">
			<view v-for="(item, index) in paperList" :key="item.id" class="d-flex flex-row p-2 chapter_con mt-3"
					@click="gotoMoni(item)">
				<view class="d-flex flex-column" style="width: 620upx;">
					<view class="d-flex flex-row flex-nowrap">
						<view class="chapter_icon">
							<image src="../../static/icon/exam_icon.png" style="width: 30upx;height: 30upx;"></image>
						</view>
						<view class="chapter_title">
							<text>{{ item.paperName }}</text>
						</view>
					</view>
					<view class="d-flex flex-row">
						<view class="w-50">
							<text>共</text><text class="mx-1 total_num">{{ item.questionNum }}</text><text>题</text>
						</view>
						<view class="w-50">
							<text>得分:</text><text class="mx-1 right_rate">{{ item.simulateScore }}</text>
						</view>
					</view>
				</view>
				<view class="arrow_right">
					<image class="mt-4" src="../../static/icon/arrow_right.png" style="width: 50upx;height: 50upx;">
					</image>
				</view>
			</view>
			
			<uni-fab horizontal="right" :pattern="pattern" @fabClick="createPaper"></uni-fab>

		</view>
		<view style="text-align: center;font-size: 24upx;color: #868686;">
			<text>已经到底了</text>
		</view>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#425ca1',
					selectedColor: '#007AFF',
					buttonColor: '#425ca1',
					iconColor: '#fff',
				},
				
				paperList: []
			}
		},
		
		onPullDownRefresh() {
			uni.showToast({
				title: "刷新成功",
				duration: 1500
			})
			setTimeout(() => {
				//this.list = ['New Item1', 'New Item2', ...];
			    uni.stopPullDownRefresh(); // 数据更新完成后停止下拉刷新
			}, 2000);
		},
		onLoad() {
			this.getMoniGrade()
		},
		methods: {
			
			getMoniGrade(){
				let url = '/moni/moniGrade'
				this.$H.post(url, {}, {token: true}).then(res=>{
					if(!res || res.code != 200){
						return uni.showToast({
							title: '获取数据失败'
						})
					}
					this.paperList = res.result
					
				}).catch( err =>{
					if(err.msg){
						uni.showToast({
							title: err.msg,
							icon: 'none'
						})
					}
				})
			},
		
			// 创建模拟试卷
			createPaper() {
				uni.navigateTo({
					url: '/pages/moni/create_moni'
				})
			},
			
			gotoMoni(item){
				uni.navigateTo({
					url: "/pages/moni/paper_analysis?examId=" + item.id + "&staffId=" + item.staffId + "&paperId=" + item.paperId
				})
			}

		}
	}
</script>

<style>
	page {
		height: 100%;
		background: #f1f1f1;
	}

	.chapter_con {
		background-color: #ffffff;
		line-height: 60upx;
		border-radius: 10upx;
		box-shadow: 0px 0px 10px rgba(0, 0, 0, 0);
		font-size: 24upx;
	}

	.arrow_right {
		width: 50upx;
		line-height: 120upx;
	}

	.chapter_title {
		width: 570upx;
		font-weight: bold;
		font-size: 30upx;
		color: #425ca1;
	}

	.chapter_icon {
		width: 50upx;
		line-height: 60upx;
		padding-top: 7upx;
	}

	.total_num {
		font-size: 30upx;
		color: #425ca1;
		font-weight: bold;
	}

	.right_rate {
		font-size: 30upx;
		color: #d40000;
		font-weight: bold;
	}
</style>